<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>信息修改</title>
    <!-- 若您需要使用Kendo UI Professional，请联系版权人获得合法的授权或许可。 -->
    <!-- Bootstrap css -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/css/bootstrap.min.css" rel="stylesheet">
    <!-- kendo ui css -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/kendoui-2015.2.624/styles/kendo.common.min.css" rel="stylesheet">
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/kendoui-2015.2.624/styles/kendo.default.min.css" rel="stylesheet">
    <!-- font-awesome -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/fontawesome/css/font-awesome.css" rel="stylesheet">
    <!--蓝鲸提供的公用样式库 -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/bk/css/bk.css" rel="stylesheet">
    <link href="https://magicbox.bk.tencent.com/static_api/v3/bk/css/bk_pack.css" rel="stylesheet">
    <link href="./static/css/jquery-confirm.min.css" rel="stylesheet" media="screen" />
    <!-- 如果要使用Bootstrap的js插件，必须先调入jQuery -->
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/js/jquery-1.10.2.min.js"></script>
    <!-- 包括所有bootstrap的js插件或者可以根据需要使用的js插件调用　-->
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/echarts-2.0/echarts-all.js"></script>
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/js/bootstrap.min.js"></script>
    <!-- 包括所有kendoui的js插件或者可以根据需要使用的js插件调用　-->
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/kendoui-2015.2.624/js/kendo.all.min.js"></script>
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/echarts-2.0/echarts-all.js"></script>
    <script src="https://magicbox.bk.tencent.com/static_api/v3/bk/js/bk.js"></script>
    <script src="./static/js/jquery-confirm.min.js"></script>
    <script type="text/javascript">
    function validate_required(field,alerttxt)
    {
        with (field)
        {
            if (value==null||value==""){
                $.dialog({
                    title: '警告',
                    content: alerttxt
                });
                return false;
                }
            else {
                return true;
            }
        }
    }
    function validate_userInfo(field,len,text){
        with(field){
            var count = 0;
            var ext1 = /([a-z]+)/;
            var ext2 = /([A-Z]+)/;
            var ext3 = /([0-9]+)/;
            var ext4 = /([_]+)/;
            if(ext1.test(value)){count=count+1;}
            if(ext2.test(value)){count=count+1;}
            if(ext3.test(value)){count=count+1;}
            if(ext4.test(value)){count=count+1;}
            if(field=="姓名"){
                if(!(ext1.test(value[0]) || ext2.test(value[0]))){
                    $.dialog({
                        title: '警告',
                        content: text
                    });
                    return false;
                }
            }
            if(count>2 && value.length>=len){
                return true;
            }
            else{
                $.dialog({
                    title: '警告',
                    content: text
                });
                return false;
            }
        }
    }

    function validate_form(thisform)
    {
        with (thisform)
        {
            if (validate_required(姓名,"姓名不能为空")==false)
            {姓名.focus();return false}
            if (validate_required(学号,"学号不能为空")==false)
            {学号.focus();return false}
            if (validate_required(学院,"学院不能为空")==false)
            {学院.focus();return false}
            if (validate_required(班级,"班级不能为空")==false)
            {班级.focus();return false}
            with(学号){
                ext = /^[0-9]+$/
                if(!ext.test(value)){
                    $.dialog({
                        title: '警告',
                        content: "学号为数字类型"
                    });
                    学号.focus();return false
                }
            }
            with (年龄){
                if (value>22 || value<17)
                {
                  $.dialog({
                      title: '警告',
                      content: "年龄应在17~22之间"
                  });
                  年龄.focus();return false;
                }
            }
            with(电话){
                var ext = /^1[3456789][0-9]{9}$/;
                if(!ext.test(value)){
                    $.dialog({
                        title: '警告',
                        content: "请输入合法的电话号码"
                    });
                    电话.focus();return false;
                }
            }
            with(email){
                var ext = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
                if(!ext.test(value)){
                    $.dialog({
                        title: '警告',
                        content: "请输入合法的邮箱"
                    });
                    email.focus();return false;
                }
            }
            if(validate_userInfo(用户名,6,"用户名至少包含字母大小写、数字、下划线中的三种，字母开始，长度至少6位")==false){
                 用户名.focus();return false;
            }
        }
    }
    </script>
</head>

<body class="bg-white" data-bg-color="bg-white">
    <div class="king-page-box">
        <div class="king-layout1-header">
            <nav>
                <div class="king-header2 navbar navbar-blue  f14">
                    <div class="nav-container">
                        <div class="navbar-header">
                            <button class="pull-right visible-xs navbar-toggle collapsed navbar-toggle-sm" type="button" data-toggle="collapse" data-target="#king-header2-navbar-collapse"> <i class="fa fa-fw fa-ellipsis-v">                    </i> </button>
                            <a class="navbar-brand">
                                <img src="./static/logo.jpg" alt="" class="logo" style="margin-top:-5px;"> </a>
                        </div>
                        <div class="navbar-collapse collapse" id="king-header2-navbar-collapse">
                            <ul class="nav navbar-nav navbar-left hidden-sm">
                                <li>
                                    <a>
                                        <span>SZIIT学生信息管理系统</span>
                                    </a>
                                </li>
                                <li class="open">
                                    <a>
                                        <span>信息修改</span>
                                    </a>
                                </li>
                            </ul>
                            <ul class="nav navbar-nav navbar-right">
                                {%  if session['user'] %}
                                    <li>
                                        <a>
                                            <span> {{ session['user'] }} </span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="{{ url_for('logout') }}">
                                            <span> 注销 </span>
                                        </a>
                                    </li>
                                {% else %}
                                    <li>
                                        <a href="{{ url_for('login') }}">
                                            <span> 登录 </span>
                                        </a>
                                    </li>
                                {% endif %}
                                <li>
                                    <a href="{{ url_for('admin') }}">
                                        <span> 管理员登录 </span>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </nav>
             <div class="container-fluid mb0 ">
                <div class="row">
                    <div class="col-md-4"></div>
                    <div class="col-md-4">
                        <div style="text-align:center">
                            <h1>修改信息</h1>
                            <form class="form-horizontal" action="{{ url_for('finishEdit') }}" method="post" onsubmit="return validate_form(this)">
                                {% for key,value in info.items() %}
                                <div class="form-group clearfix ">
                                    <label class="col-sm-3 control-label bk-lh30 pt0">{{ key }}</label>
                                    <div class="col-sm-9">
                                        {% if key == '用户名'%}
                                        <input onfocus=this.blur() type="text" class="form-control bk-valign-top" name="{{ key }}" value="{{ value }}">
                                        {% else %}
                                        <input type="text" class="form-control bk-valign-top" name="{{ key }}" value="{{ value }}">
                                        {% endif%}
                                    </div>
                                </div>
                                {% endfor %}
                                <div class="form-group clearfix" style="text-align: center">
                                    <div class="col-sm-9 col-sm-offset-3">
                                        <button type="submit" class="king-btn mr10  king-success">提交</button>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>
                    <div class="col-md-4"></div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>